<!doctype html>
<html>		
		<head>
			<meta charset="utf-8">
			<script src="js/angular.min.js"></script>
		</head>
		<body ng-app="MyReverseModule">
			<div ng-controller="Ctrl">
		      <input ng-model="greeting" type="greeting"><br>
		      No filter: {{greeting}}<br>
		      Reverse: {{greeting | reverse}}<br>
		      Reverse + uppercase: {{greeting | reverse:true}}<br>
		    </div>
		</body>

		<script type="text/javascript">
		angular.module('MyReverseModule', []).
		  filter('reverse', function() {
		    return function(input, uppercase) {
		      var out = "";
		      for (var i = 0; i < input.length; i++) {
		        out = input.charAt(i) + out;
		      }
		      // conditional based on optional argument
		      if (uppercase) {
		        out = out.toUpperCase();
		      }
		      return out;
		    }
		  });

		function Ctrl($scope) {
		  $scope.greeting = 'hello';
		}
		</script>
</html>
